<?php

use yii\db\Migration;

class m170620_011639_statistics_day extends Migration
{
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=MyISAM';
        }

        $this->createTable('{{%statistics_day}}', [
            'id' => $this->primaryKey()->unsigned()->comment('自增id'),
            'reg_num' => $this->integer()->defaultValue(0)->comment('注册人数'),
            'pay_sum' => $this->decimal(32,2)->defaultValue(0)->comment('充值总额'),
            'pay_num' => $this->integer()->defaultValue(0)->comment('充值人数'),
            'pay_rate' => $this->decimal(32,2)->defaultValue(0)->comment('充值率'),
            'arppu'=>$this->decimal(32,2)->defaultValue(0)->comment('arppu'),
            'next_remains'=>$this->decimal(32,2)->defaultValue(0)->comment('次日留存'),
            'third_remains'=>$this->decimal(32,2)->defaultValue(0)->comment('3日留存'),
            'seven_remains'=>$this->decimal(32,2)->defaultValue(0)->comment('7日留存'),
            'thirty_remains'=>$this->decimal(32,2)->defaultValue(0)->comment('30日留存'),
            'game_name'=>$this->string(20)->defaultValue('')->comment('游戏名称'),
            'server_name'=>$this->string(20)->defaultValue('')->comment('区服'),
            'guild_sign'=>$this->string(20)->defaultValue('')->comment('公会标识'),
            'record_time'=>$this->integer(12)->defaultValue(0)->comment('最后记录时间(根据用户表)'),
            'date'=>$this->string(32)->defaultValue('')->comment('日期'),
        ], $tableOptions);
        $this->createIndex('guild','statistics_day',['game_name','guild_sign','date'],true);
    }

    public function down()
    {
        $this->dropTable('{{%statistics_day}}');
    }
}
